﻿#include "UCustomCurveListUMG.h"

#include "ListLibrary/ListUIStyle.h"

UCustomCurveListUMG::UCustomCurveListUMG()
	:MaxValue(100)
	,GrowValue(20)
,UseCurveLine(false)
,ShowArea(false)
,UseRand(true)
,UseRuler(true)
{

}

TSharedRef<SWidget> UCustomCurveListUMG::RebuildWidget()
{
	CustomCurveList = SNew(SCustomCurveList);
	return CustomCurveList.ToSharedRef();
}

const FText UCustomCurveListUMG::GetPaletteCategory()
{
	return FText::FromString(TEXT("小辉辉"));
}

//资源释放
void UCustomCurveListUMG::ReleaseSlateResources(bool bReleaseChildren)
{
	Super::ReleaseSlateResources(bReleaseChildren);
	CustomCurveList.Reset();
}

void UCustomCurveListUMG::UpDataList(TMap<FString,FCustomCurveListInfo> ListData)
{
	CustomCurveList->UpDataList(ListData);
}

//更新UI
void UCustomCurveListUMG::SynchronizeProperties()
{
	Super::SynchronizeProperties();
	CustomCurveList->UpDataTitleName(Title);
	CustomCurveList->UpDataOneInfoName(OneInfo);
	CustomCurveList->UpDataTwoInfoName(TwoInfo);
	CustomCurveList->UpDataThreeInfoName(ThreeInfo);
	CustomCurveList->UpDataFourInfoName(CustomInfo);

	
	if(GrowValue * 2 > MaxValue)
	{
		GrowValue = MaxValue / 2;
	}
	CustomCurveList->ShowTitle = ShowTitle;
	//表格中的最大值
	CustomCurveList->MaxValue = MaxValue;
	//递增区间
	CustomCurveList->GrowValue = GrowValue;
	//柱子的个数
	CustomCurveList->PillarNum = PillarNum;
	//使用曲线
	CustomCurveList->UseCurveLine = UseCurveLine;
	//显示面积
	CustomCurveList->ShowArea = ShowArea;
	//使用随机数
	CustomCurveList->UseRand = UseRand;
	//使用刻度尺
	CustomCurveList->UseRuler = UseRuler;
	//重新绘制表格
	CustomCurveList->UpdataCustomCurveList();
	
}